package com.gzx.plugin.tjzy.modular.call.scripts.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.gzx.plugin.tjzy.modular.call.scripts.bo.GzxCallScriptsAddOrEditBo;
import com.gzx.plugin.tjzy.modular.call.scripts.bo.GzxCallScriptsQueryBo;
import com.gzx.plugin.tjzy.modular.call.scripts.entity.GzxCallScripts;
import com.gzx.plugin.tjzy.modular.call.scripts.mapper.GzxCallScriptsMapper;
import com.gzx.plugin.tjzy.modular.call.scripts.service.GzxCallScriptsService;
import com.gzx.plugin.tjzy.modular.call.scripts.vo.GzxCallScriptsVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import vip.xiaonuo.common.mvc.service.impl.BaseServiceImpl;

import java.util.List;

/**
 * @author zjt
 * @description
 * @date 2025/1/22 15:08
 */
@Service
@DS("tjzy")
public class GzxCallScriptsServiceImpl extends BaseServiceImpl<GzxCallScriptsAddOrEditBo, GzxCallScriptsVo, GzxCallScriptsQueryBo, GzxCallScriptsMapper, GzxCallScripts> implements GzxCallScriptsService {

    public GzxCallScriptsServiceImpl(GzxCallScriptsMapper baseMapper) {
        super(baseMapper);
    }

    /**
     * 获取全部话术
     *
     * @return
     */
    @Override
    @DS("tjzy")
    public List<GzxCallScripts> listAll() {
        return baseMapper.selectList();
    }

    @Override
    protected LambdaQueryWrapper<GzxCallScripts> buildQueryWrapper(GzxCallScriptsQueryBo queryBo) {
        return Wrappers.<GzxCallScripts>lambdaQuery()
                .eq(StringUtils.isNotBlank(queryBo.getIntent()), GzxCallScripts::getIntent, queryBo.getIntent())
                .like(StringUtils.isNotBlank(queryBo.getSubject()), GzxCallScripts::getSubject, queryBo.getSubject())
                .orderByDesc(GzxCallScripts::getId);
    }
}
